function [act logact] = gaussBayesUncertainty(m, b, W, v, ElndetLambda, data, R, E, RRt, logdetE)


[N D] = size(data.Y);

DD = D*D;
Dlog2pi = D*log(2*pi);
invC = data.invC;
invC_vec = reshape(data.invC, DD, N);
logdetC = data.logdetC;
invCy = data.invCy;
yinvCy = data.yinvCy;
RRt_vec = reshape(RRt, DD, N);

centered_R = R - ones(N, 1)*m;
exp_dist2 = D/b + v*sum(centered_R*W.*centered_R, 2);

% E[ln p(xn|mk, Lk)]
logact =  - Dlog2pi + ElndetLambda - exp_dist2;
logact = logact - v*(reshape(E, DD, N)'*W(:));

% E[ln p(yn|Cn, xn)]
logact = logact - Dlog2pi - logdetC;
logact = logact - sum(invC_vec.*RRt_vec, 1)' + sum(2*invCy.*R, 2) - yinvCy - squeeze(sum(sum((E.*invC), 1), 2));

% E[ln q(xn)]
logact = logact + D + Dlog2pi + logdetE;

logact = logact*0.5;

act = exp(logact);
